//
//  TFFullView.swift
//  TalkfunSDKDemo
//
//  Created by 莫瑞权 on 2022/5/6.
//  Copyright © 2022 Talkfun. All rights reserved.
//

import UIKit

public class TFFullView: UIView {

    @objc public weak var delegate : TFFullViewDelegate?
    @objc public let zoomButton = UIButton()
    @objc public var model = TalkfunRtcModel()
    @objc public let noStartImg = UIImageView()//占位图
    @objc public let view = UIView()
    override init(frame: CGRect) {
        super.init(frame: frame)
        

        
        let doubleTap = UITapGestureRecognizer.init(target: self, action: #selector(self.doubleTapAction))
        doubleTap.numberOfTapsRequired = 2
        self.addGestureRecognizer(doubleTap)
        
        self.view.isHidden = true
        self.view.backgroundColor = UIColor(red: 33/255.0, green: 38/255.0, blue: 46/255.0, alpha: 1)
        self.addSubview(self.view)
    
        self.noStartImg.image = UIImage.init(named: "HTLive.bundle/closevideo-yinliang")
        self.view.addSubview(self.noStartImg)
        

        self.zoomButton.backgroundColor = UIColor(red: 13/255.0, green: 15/255.0, blue: 18/255.0, alpha: 0.6)
       
        self.addSubview(self.zoomButton)
        self.zoomButton.setImage(UIImage.init(named: "HTLive.bundle/shrink1vN"), for: .normal)
        self.zoomButton.addTarget(self, action: #selector(self.zoomButtonClick), for: .touchUpInside)
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    public override func layoutSubviews() {
        super.layoutSubviews()
        self.view.frame = self.bounds
        
        self.zoomButton.frame = CGRect(x: self.frame.size.width-44-20, y: self.frame.size.height-44-15, width: 44, height: 44)
       
        self.zoomButton.layer.masksToBounds = true
        self.zoomButton.layer.cornerRadius = 22
        
        self.noStartImg.frame = CGRect(x: (self.view.frame.size.width-160)/2, y: (self.view.frame.size.height-160)/2, width: 160, height: 160) 
    }
    @objc func zoomButtonClick()
    {
        if self.delegate != nil && (self.delegate?.responds(to: #selector(TFFullViewDelegate.objectFullViewDidDragged(_:))))!{
            
            
            self.delegate?.objectFullViewDidDragged(self)
        }

    }
  
    @objc func doubleTapAction()
    {
        self.zoomButtonClick()
    }

}

@objc public protocol TFFullViewDelegate : NSObjectProtocol {

    func objectFullViewDidDragged(_ vc : TFFullView)

}
